Yacon.widget.TPictureBox = function(conText){
	
	Yacon.apply(this,conText);
	
	if(!Yacon.isEmpty(this.view)){
		this.element = this.view;
		this.elementID = this.view.id;
		this.elementType = this.view.type;
	}
	
	this.picArray = new Array();
	
};

Yacon.widget.TPictureBox.prototype = {
	
	/* 获取HTML信息 */	
	getHtml : function(){
		
		var html = "";
		
		html += "<div ";		
		html += " lily-id='"+this.elementID+"' lily-type='"+this.elementType+"' ";	
		html += " style='padding-left:15px;padding-right:15px;' ";
		html += " >";
		
		if(!Yacon.isEmpty(this.view.title) || !Yacon.isEmpty(this.view.ico)){
					
			var style = "";
			
			if(!this.view.isTitle){
				style += "display:none;";
			}
			
			html += "<div class='picbox-title' style='"+style+"' >";
			
			html += "<button type='button' lily-player='button' btn-id='XXX' class='btn btn-default bk-bg-primary' ";

			html += " style='border-radius: 0px;' ";
			
			html += ">";
			
			if(!Yacon.isEmpty(this.view.ico)){
				html += "<span class='"+this.view.ico+"'></span>";
				html += "&nbsp;&nbsp;";
			}
			
			if(!Yacon.isEmpty(this.view.title)){		
				html += this.view.title;			
			}
			
			if(Yacon.isTrue(this.view.isBadge)){
				html += "&nbsp;&nbsp;";
				html += "&nbsp;&nbsp;";
				html += "<span class='badge' style='background-color: #fff;color: #333;top:0px;'>"+this.view.pictures.length+"</span>";				
			}
	
			html += "</button>";
			html += "</div>";
			
		}
			
		html += "<div class='row' >";
		
		this.pictures = this.view.pictures;
		
		if(!Yacon.isEmpty(this.pictures)){
			for(var i=0;i<this.pictures.length;i++){			
							
				var offsetClass = "";
				
				if(this.view.offset > 0){
					offsetClass += " col-md-offset-"+this.view.offset;
				}
				
				if(!Yacon.isEmpty(this.view.menu)){
					
					if(i==0){
						html += "<div class='col-md-"+this.view.picWidth+offsetClass+"' data-toggle='context' data-target='#"+this.elementID+"-menu' >";					
					}else{
						html += "<div class='col-md-"+this.view.picWidth+"' data-toggle='context' data-target='#"+this.elementID+"-menu' >";					
					}
					
				}else{
					
					if(i==0){
						html += "<div class='col-md-"+this.view.picWidth+offsetClass+"' >";
					}else{
						html += "<div class='col-md-"+this.view.picWidth+"' >";
					}

				}
				
				this.pictures[i].src = getAbsolutePath(this.pictures[i].src);
				
				var activePic = new Yacon.widget.TPicture({view:this.pictures[i],page:this.page,parent:this,picIdx:i});
				
				this.picArray.add(activePic);
				
				html += activePic.getHtml();
				
				html += "</div>";
				
			}
		}	
		
		html += "</div>";
		
		this.carousel = new Yacon.widget.TCarousel({
			parent : this,
			pictures : this.picArray,
			elementID : this.elementID+"_srollBox_pics",
			elementType : "carousel",
			isWrap: this.view.isWrap
		});
		
		if(this.view.menu){
			
			this.menu = new Yacon.widget.TMenu(this.view.menu);
			this.menu.parent = this;
			this.menu.page = this.page;
			this.menu.dataSet = new Yacon.data.DataSet(this.page);
			
			html += this.menu.getHtml();
			
		}
		
		html += "</div>";
		
		return html;
		
	},
	
	addEvents: function(){
		
		var search = this.page.element.search + " div[lily-id='"+this.elementID+"'][lily-type='"+this.elementType+"']";
		var allPictures = $(search+" .row a");
		var self = this;
		
		for(var i=0;i<allPictures.length;i++){
			
			allPictures.eq(i).unbind("click");
			allPictures.eq(i).click(function(){
				
				var activeImg = $(this).find("img");			
				self.carousel.show(activeImg);	
				
			});
			
			allPictures.eq(i).unbind("mouseover");
			allPictures.eq(i).mouseover(function(){
				
				var activeImg = $(this).find("img");			
				self.activeImg = activeImg;	
				
			});
			
		}
		
		if(this.menu){
			this.menu.addRightClick(" #"+this.elementID+"-menu ");
		}
		
	},
	
	getActiveImg:function(){
		return this.activeImg;
	},
	
	getActiveImgSrc:function(){
		return this.activeImg.prop("src");
	},
	
	layoutBefore: function(){
		
	}

};